Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clients): generate code snippets from cts #2511

Merged
merged 20 commits into from
Jan 10, 2024

Conversation

shortcuts
Copy link
Member

@shortcuts shortcuts commented Jan 9, 2024

🧭 What and Why

🎟 JIRA Ticket: https://algolia.atlassian.net/browse/DI-1749

Changes included:

This PR registers a new generator in order to generate code snippets for each method of each languages, it is completely based on the CTS request generator and will take the first test case of each method as the example.

The snippets are generated for

  • java
  • javascript
  • python
  • php

Generators change

I had to change the output folder and template dir in order to fully reuse the TestsRequest generator, which means each template has been edited to include the tests folder when using partial templates

clients.config.json

A new field named snippets allows us to store the output folder and the file extension, similarly to what we do for tests

CI

We now store the snippets in the artifacts and restore them in order to be pushed by the CI

What's next

  • Add snippets for missing clients
  • Improve first test case variable values and descriptions

Copy link

netlify bot commented Jan 9, 2024

Deploy Preview for api-clients-automation ready!

Name Link
🔨 Latest commit 1624f04
🔍 Latest deploy log https://app.netlify.com/sites/api-clients-automation/deploys/659ec610a5cd200009c32f64
😎 Deploy Preview https://deploy-preview-2511--api-clients-automation.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@algolia-bot
Copy link
Collaborator

algolia-bot commented Jan 9, 2024

✗ The generated branch has been deleted.

If the PR has been merged, you can check the generated code on the main branch.
You can still access the code generated on main via this commit.

@shortcuts shortcuts marked this pull request as ready for review January 10, 2024 14:41
@shortcuts shortcuts requested a review from a team as a code owner January 10, 2024 14:41
@shortcuts shortcuts self-assigned this Jan 10, 2024
Fluf22
Fluf22 previously approved these changes Jan 10, 2024
Copy link
Contributor

@Fluf22 Fluf22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh nice

Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so cool, almost nothing to add !

@@ -43,6 +43,9 @@ export async function ctsGenerateMany(generators: Generator[]): Promise<void> {
await run('YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install', {
cwd: 'tests/output/javascript',
});
await run('YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install', {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be in a totally different file, like scripts/snippets/generate.ts

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not yet created the CLI stuff, I know you want to do it :D

Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's start with that !

@shortcuts shortcuts merged commit 857f363 into main Jan 10, 2024
27 checks passed
@shortcuts shortcuts deleted the feat/code-snippets-from-cts branch January 10, 2024 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants